import "@scss/register.scss"
import http from "../utils/request.js";


$("body").on("blur", "#confirmPass", function () {
    const userpass = $("#password").val();
    const confirmPass = $("#confirmPass").val();

    if (userpass != confirmPass) {
        $(".box2 p").html("两次密码输入不相符！");
    }
});



$("body").on("click", "#registerBtn", async function () {

    const userPhone= $("#userPhone").val();
    const passWord = $("#password").val();
    const confirmPass = $("#confirmPass").val();
    if (confirmPass == passWord&& userPhone) {

        let mes = await http({ url: "/api/register/register", type: "post", data: { userPhone, passWord } });

        if (mes.code != -1) {
            localStorage.setItem("token", mes.token);
            window.location.href = "./firstpage.html";
        } else {
            alert("登录失败")
        }
    } else {
        alert("输入有误！")
    }

})